package com.cn.mmd.service;

import com.cn.mmd.mapper.QuestionnaireStudentMapper;
import com.cn.mmd.mapper.StudentAppMapper;
import com.cn.mmd.mapper.StudentMapper;
import com.cn.mmd.model.QuestionnaireStudent;
import com.cn.mmd.model.Student;
import com.cn.mmd.model.StudentApp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/6/28 0028.
 */
@Service("studentService")
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    StudentAppMapper studentAppMapper;
    @Autowired
    QuestionnaireStudentMapper questionnaireStudentMapper;

    @Override
    public Student selectByKey(String studentid) {
        return studentMapper.selectByKey(studentid);
    }

    @Override
    public int insertSelective(Student record) {
        return studentMapper.insertSelective(record);
    }

    @Override
    public int deleteByPrimaryKey(String studentid) {
        return studentMapper.deleteByPrimaryKey(studentid);
    }

    @Override
    public ArrayList<Student> selectByAll() {
        return (ArrayList<Student>) studentMapper.selectByAll();
    }

    @Override
    public List<Student> selectByAllEx(String string) {
        return  studentMapper.selectByAllEx(string);
    }

    @Override
    public List<Student> selectByClass(String string) {
        return studentMapper.selectByClass(string);
    }

    @Override
    public Student selectByPrimaryKey(String studentid) {
        return studentMapper.selectByPrimaryKey(studentid);
    }

    @Override
    public List<Student> selectByPaging(Student student) {
        return studentMapper.selectByPaging(student);
    }

    @Override
    public int updateByPrimaryKeySelective(Student record) {
        return studentMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int countLimitNum(Student student) {
        return studentMapper.countLimitNum(student);
    }

    /**
     * 查看我的基本数据
     * @param studentId
     * @return
     */
    public StudentApp selectData(String studentId) {
        return studentAppMapper.selectByPrimaryKey(studentId);
    }


    /**
     * 添加问卷-学生关联表
     * @param questionnaireStudent
     * @return
     */
    public int insertStuQues(QuestionnaireStudent questionnaireStudent){
        return questionnaireStudentMapper.insertSelective(questionnaireStudent);
    }

    /**
     * 通过问卷id删除问卷-学生关联
     * @param questionnaireId
     * @return
     */
    public int delStuQues(int questionnaireId){
        return questionnaireStudentMapper.delStuQues(questionnaireId);
    }

    /**
     * 查询问卷-学生关联表(通过时间排序 查询未填写的问卷)
     * @param questionnaireStudent
     * @return
     */
    public List<QuestionnaireStudent> selectStuQues(QuestionnaireStudent questionnaireStudent){
        return questionnaireStudentMapper.selectStuQues(questionnaireStudent);
    }

    /**
     * 查询与学生关联的未填写的问卷数
     * @param questionnaireStudent
     * @return
     */
    public int selectCountStuQues(QuestionnaireStudent questionnaireStudent){
        return questionnaireStudentMapper.selectCountStuQues(questionnaireStudent);
    }


    /**
     * 修改问卷学生关联表状态
     * @param questionnaireStudent
     * @return
     */
    public int updateState(QuestionnaireStudent questionnaireStudent){
        return questionnaireStudentMapper.updateState(questionnaireStudent);
    }

    /**
     * 学生学院去重
     * @return
     */
    @Override
    public List<Student> selectCollegeByAll() {
        return studentMapper.selectCollegeByAll();
    }

    @Override
    public List<Student> selectMajorByAll(String s) {
        return studentMapper.selectMajorByAll(s);
    }

    @Override
    public List<Student> selectByMa(Student student) {
        return studentMapper.selectByMa(student);
    }

    @Override
    public List<Student> selectByCo(Student student) {
        return studentMapper.selectByCo(student);
    }

    /**
     * 根据专业查看学生班级去重
     * @param student
     * @return
     */
    public List<Student> selectByMajor(Student student){
        return studentMapper.selectByMajor(student);
    }


    /**
     * 查询根据年级
     * @param string
     * @return
     */
    public List<Student> selectByClasss(String string){
        return  studentMapper.selectByClasss(string);
    }
}
